﻿namespace TriangleGames.TrainRes
{
    using System;
    using System.Collections.Generic;
    using System.Runtime.InteropServices;

    public class ActionReport
    {
        public FsmStateAction action;
        public int actionIndex;
        public static readonly List<ActionReport> ActionReportList = new List<ActionReport>();
        public static int ErrorCount;
        public TrainResFSMCore fsm;
        public static int InfoCount;
        public bool isError;
        public string logText;
        public FsmState state;

        public static void Clear()
        {
            ActionReportList.Clear();
        }

        public static int GetCount()
        {
            return ActionReportList.Count;
        }

        public static void Log(TrainResFSMCore fsm, FsmState state, FsmStateAction action, int actionIndex, string logLine, [Optional, DefaultParameterValue(false)] bool isError)
        {
            ActionReport report2 = new ActionReport();
            report2.fsm = fsm;
            report2.state = state;
            report2.action = action;
            report2.actionIndex = actionIndex;
            report2.logText = logLine;
            report2.isError = isError;
            ActionReport item = report2;
            ActionReportList.Add(item);
            InfoCount++;
        }

        public static void LogError(TrainResFSMCore fsm, FsmState state, FsmStateAction action, int actionIndex, string logLine)
        {
            Log(fsm, state, action, actionIndex, logLine, true);
            ErrorCount++;
        }

        public static void Start()
        {
            ActionReportList.Clear();
            InfoCount = 0;
            ErrorCount = 0;
        }
    }
}

